package com.mcc.myapplication

import kotlin.concurrent.thread


//sampleStart
fun getStringLength(obj: Any): Int? {
    if (obj is String) {
        // `obj` 在该条件分支内自动转换成 `String`
        return obj.length
    }

    // 在离开类型检测分支后，`obj` 仍然是 `Any` 类型
    return null
}
//sampleEnd 和手机最大的区别

fun main() {
    fun printLength(obj: Any) {
        println("Getting the length of '$obj'. Result: ${getStringLength(obj) ?: "Error: The object is not a string"} ")
    }

    printLength("Incomprehensibilities")
    printLength(1000)
    printLength(listOf(Any()))

    Thread {
        // 编写具体的逻辑
        println("hello Thread")
    }.start()

    thread {
        // 编写具体的逻辑
        println("hello thread")
    }

    println("println...")

    val requests = listOf(
        Request("hello", 200),
        Request("hello", 400),
        Request("world", 2300)
    )
    println(requests.groupBy(Request::url, Request::responseCode))
}

